#include "dialogrecord.h"
#include "ui_dialogrecord.h"
#include <QStandardItemModel>
#include <QDir>
#include <QtSql/QSqlError>

Dialogrecord::Dialogrecord(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialogrecord)
{
    ui->setupUi(this);
    diastartinit();
}

Dialogrecord::~Dialogrecord()
{
    delete ui;
}

void Dialogrecord::on_pushButton_clicked()
{
    this->parentWidget()->show();
    delete this;
}

void Dialogrecord::diastartinit()
{
    QStandardItemModel* model=new QStandardItemModel(this);
    model->setColumnCount(4);
    model->setHeaderData(0,Qt::Horizontal,"id");
    model->setHeaderData(1,Qt::Horizontal,"date");
    model->setHeaderData(2,Qt::Horizontal,"type");
    model->setHeaderData(3,Qt::Horizontal,"message");
    model->setItem(0, 0, new QStandardItem("1"));
    model->setItem(0, 1, new QStandardItem("2019/6/16 15:00"));
    model->setItem(0, 2, new QStandardItem("light on"));
    model->setItem(0, 3, new QStandardItem("windows on"));
    ui->tableView->setModel(model);
    ui->tableView->show();
}
